package com.neuedu.yyzx.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.neuedu.yyzx.po.Emp;
import com.neuedu.yyzx.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
//允许跨域
@CrossOrigin
@RequestMapping("/emp")
public class EmpController {
	@Autowired
	private EmpService empService;
	//可以改成GetMapping
	@RequestMapping("/getPage")
	public IPage<Emp> getPage(int curr,int size,String inputName,String inputHireDate){
		return empService.getPage(curr, size,inputName,inputHireDate);
	}
	@RequestMapping("/addEmp")
	public int addEmp(String ename,String job) {
		int num = empService.addEmp(ename, job);
		return num;
	}
	@RequestMapping("/addUser")
	public int addUser(@RequestBody Emp userForm) {
//		System.out.println("yes");
//		System.out.println(userForm.getHiredate());
		int num = empService.addEmp(userForm);
		return num;
	}
	@RequestMapping("/delUser")
	public int delUser(String empno) {
		System.out.println(empno);
		int num = empService.delUser(empno);
		return num;
	}
	@RequestMapping("/updateUser")
	public int updateUser(@RequestBody Emp userForm) {
//		System.out.println("yes");
		//System.out.println(userForm.getEname());
		int num = empService.updateUser(userForm);
		return num;
	}
	@RequestMapping("/delUserMany")
	public int updateUser(@RequestBody String[] ids) {
		int num = empService.delUserMany(ids);
		return num;
	}
}
